/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.google.code.jmarias.client.tcp;

import org.newdawn.slick.AppGameContainer;
import org.newdawn.slick.BasicGame;
import org.newdawn.slick.Color;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.UnicodeFont;
import org.newdawn.slick.font.effects.ColorEffect;

public class FontTestGame extends BasicGame {
   private static UnicodeFont font;

   private FontTestGame () throws SlickException {
      super("Te\u010f je pr\u00e1v\u011b");
   }

   public static void main (String[] args) throws SlickException {
      FontTestGame game = new FontTestGame();
      AppGameContainer container = new AppGameContainer(game, 640, 480, false);
      container.setSmoothDeltas(true);
      container.setVSync(true);
      container.setTargetFrameRate(60);
      container.start();
   }

   public void init (GameContainer container) throws SlickException {
      font = new UnicodeFont(new java.awt.Font("Arial", java.awt.Font.ITALIC, 26));

      // Fonts are drawn using org.newdawn.slick.font.effects.Effect. Without at least one effect, nothing is drawn.
      // If you use a .hiero file saved with the Hiero tool, then you don't need to add effects programmatically.
      // This is a simple effect that just fills in the glyphs with a color.
      // White lets us tint the font to any color at runtime.
      font.getEffects().add(new ColorEffect(java.awt.Color.white));

      // A TrueType font can contain 65536 glyphs. We don't want to load all possible glyphs up front!
      // This code adds the glyphs in the ASCII range (32 to 255) then tells the font to load them.
      font.addAsciiGlyphs();
      font.loadGlyphs();
   }

   public void update (GameContainer container, int delta) throws SlickException {
   }

   public void render (GameContainer container, Graphics g) throws SlickException {
      g.setFont(font);
      g.setColor(Color.white);
      g.drawString("P\u0159\u00edli\u0161 \u017elu\u0165ou\u010dk\u00fd k\u016f\u0148 \u00fap\u011bl \u010f\u00e1belsk\u00e9 k\u00f3dy.", 30, 30);

      font.drawString(30, 80, "Does this work?", Color.red); // Text tinted red.

      // If a font is asked to draw glyphs it does not have loaded, they are added to the font.
      // Calling this in the game loop causes any unloaded glyphs to be loaded on the fly.
      font.loadGlyphs(5);
      // If you only need ASCII, you can preload all the glyphs and don't need this in the game loop.
      // On the fly loading is required when you can't know all glyphs needed up front.
      // Eg, imagine someone typing Chinese charatcers into a text box.
   }
}